package com.zf.zffencheng.controller.admin;


import com.zf.zffencheng.model.Result;
import com.zf.zffencheng.model.vo.AccountVo;
import com.zf.zffencheng.model.vo.AdminLoginInfoVo;
import com.zf.zffencheng.model.vo.HomePageVo;
import com.zf.zffencheng.service.AccountService;
import com.zf.zffencheng.util.UserContextUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: AdminController <br/>
 * Description:  <br/>
 * date: 2021/5/11 16:15<br/>
 *
 * @author william <br/>
 */
@Api(tags = "账号管理")
@RestController
@RequestMapping("/sapi/v1/admin/account")
public class AdminAccountController {

    private final AccountService accountService;

    public AdminAccountController(AccountService accountService) {
        this.accountService = accountService;
    }

    @ApiOperation("当前账户余额+待结算金额")
    @GetMapping("current")
    public Result currentAccount(){
        AdminLoginInfoVo currentAdminInfo = UserContextUtils.getCurrentAdminInfo();
        AccountVo accountVo = accountService.getAccount(currentAdminInfo);
        return Result.ok(accountVo);
    }
    @ApiOperation("首页数据：今日收益+昨日收益+今日订单+总收益金额")
    @GetMapping("homePage")
    public Result homePage(){
        AdminLoginInfoVo currentAdminInfo = UserContextUtils.getCurrentAdminInfo();
        if(null == currentAdminInfo){

        }

        HomePageVo homePageVo = accountService.getHomePageVo(currentAdminInfo.getAdminId(),currentAdminInfo.getAccountId(),currentAdminInfo.getAdminType());
        return Result.ok(homePageVo);
    }

}
